package com.kstech.mp3604.fragments


import android.content.Intent
import android.provider.Settings
import androidx.navigation.fragment.findNavController
import com.kstech.mp3604.R
import com.kstech.mp3604.base.BaseDialogFragment
import com.kstech.mp3604.databinding.FragmentDeviceSettingBinding
import com.kstech.mp3604.ui.listener.SettingNewDialogListener
import com.kstech.mp3604.utils.VersionUtil

/**
 * 设置按钮
 */
class DialogSettingFragment(
    val listener: SettingNewDialogListener
) : BaseDialogFragment<FragmentDeviceSettingBinding>(FragmentDeviceSettingBinding::inflate) {


    override fun onInitView() {

        binding.apply {
            versionName.text = "软件版本号:${VersionUtil.getAppVersionName(requireContext())}"
            closeDialog.setOnClickListener {
                dialog!!.cancel()
            }
            screenSettingButton.setOnClickListener {
                val intent = Intent(Settings.ACTION_DISPLAY_SETTINGS)
                startActivity(intent)
                dialog!!.cancel()
            }
            timeSettingButton.setOnClickListener {
                val intent = Intent(Settings.ACTION_DATE_SETTINGS)
                startActivity(intent)
                dialog!!.cancel()
            }
            netSettingButton.setOnClickListener {
                val intent = Intent(Settings.ACTION_WIFI_SETTINGS)
                startActivity(intent)
                dialog!!.cancel()
            }
            paraSettingButton.setOnClickListener {
                dialog!!.cancel()
                DialogLoginSetParamFragment().show(parentFragmentManager)
            }
//            startPointSetting.setOnClickListener {
//                listener.showStartPointDialog()
//                dialog!!.cancel()
//            }
            bindWareHouse.setOnClickListener {
                listener.showBindWareHouseDialog()
                dialog!!.cancel()
            }
            autoMoveButton.setOnClickListener {
                DialogAutoHYFragment().show(parentFragmentManager)
                dialog!!.cancel()
            }

            testUiButton.setOnClickListener {
//                listener.showTestUiDialog()
                dialog!!.cancel()
            }

            testSerialButton.setOnClickListener {
                findNavController().navigate(R.id.action_dmFragment_to_testSerialCommFragment)
                dialog!!.cancel()
            }
            dialogIpPortButton.setOnClickListener {
                DialogIpPortSettingFragment().show(parentFragmentManager)
                dialog!!.cancel()
            }
            appFinishedBtn.setOnClickListener {
                requireActivity().finish()
            }
            openControlInitConfig.setOnClickListener {
                DialogInitConfigFragment().show(parentFragmentManager)
                dialog!!.cancel()
            }
            dialogIpPortButton.setOnClickListener {
                DialogIpPortSettingFragment().show(parentFragmentManager)
                dialog!!.cancel()
            }
        }
    }
}